using System.Collections.Generic;
using BBX.Common;
using BBX.Entity;
using BBX.Forum;

namespace BBX.Web
{
	public class showratelist : PageBase
	{
		public System.Int32 postid = DNTRequest.GetInt("pid", 0);
		public List<RateLog> rateloglist = new List<RateLog>();
		public System.String[] scorename = Scoresets.GetValidScoreName();
		public System.String[] scoreunit = Scoresets.GetValidScoreUnit();
		public System.Int32 ratecount;
		public System.Int32 pagecount;
		public System.Int32 pagesize = 10;
		public System.Int32 pageid = DNTRequest.GetInt("page", 0);
		public System.String pagenumbers = "";

		protected override void ShowPage()
		{
			if (postid > 0)
			{
                pagetitle = "帖子ID为" + postid + "的评分列表";
                //this.ratecount = Posts.GetPostRateLogCount(this.postid);
                //this.rateloglist = Posts.GetPostRateLogList(this.postid, this.pageid, this.pagesize);
                ratecount = RateLog.SearchCount(0, postid);
                rateloglist = RateLog.Search(0, postid, (pageid - 1) * pagesize, pagesize);
                pagecount = ((ratecount % pagesize == 0) ? (ratecount / pagesize) : (ratecount / pagesize + 1));
                pagecount = ((pagecount == 0) ? 1 : pagecount);
                pageid = ((pageid < 1) ? 1 : pageid);
                pageid = ((pageid > pagecount) ? pagecount : pageid);
                pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showratelist.aspx?pid=" + postid, 8);
			}
		}

		public System.String GetExtCreditName(System.Int32 extCredit)
		{
			return scorename[extCredit];
		}

		public System.String GetExtCreditUnit(System.Int32 extCredit)
		{
			return scoreunit[extCredit];
		}

		public System.String GetAvatarUrl(System.Int32 uid)
		{
			return Urls.UserInfoAspxRewrite(uid);
		}

		public System.String GetScoreMark(System.Int32 value)
		{
			if (value <= 0)
			{
				return "";
			}
			return "+";
		}
	}
}